{include file="Public:header" /}
<style>
.item-content.img_top{
	-webkit-box-align: inherit;
	-webkit-align-items: inherit;
	align-items: inherit;
}
.item-content.img_top .div_block{
	display: block;
    padding-top: 1rem;
}
</style>
		<div class="bar bar-nav">
			<h1 class="title">讨论列表 ({$discuss_count})</h1>
			<i class="icon icon-left" onclick="window.history.go(-1);"></i>
		</div>
		<nav class="bar discuss_nav bar-tab">
				<input onclick="discuss_form('','')" readonly="readonly" type="text" placeholder="我要讨论.." />
		</nav>

		<div class="content">
			<div class="row discuss no-border" style="margin-top:0;">
				<div class="col-100">
					<div class="content-padded">
						<div class="list-block media-list" style="margin-top:0;">
							<ul id="discuss_ul">
							{foreach name="discuss" item="discuss" key="k"}
								<li class="item-content img_top">
									<div class="item-media div_block">
										<img src="{$discuss['head_img']}">
									</div>
									<div class="item-inner" onclick="discuss_form({$discuss['user_id']},'{$discuss['nickname']}')">
										<div class="item-title-row">
											<div class="item-title">{$discuss['nickname']}<span class="pull-right">{$discuss['add_time']|date="Y-m-d",###}</span></div>
										</div>
										{if condition="$discuss['reply_user_id']"}
										<div class="item-title" style="line-height:20px;text-indent: 1em;color: #999;">回复&nbsp; {$discuss['reply_nickname']}：</div>
										{/if}
										<div class="item-subtitle">{$discuss['content']}</div>
									</div>
								</li>
							{/foreach}
							</ul>
						</div>
					</div>
				</div>
			</div>
			
			<div class="infinite-scroll-preloader" style="display:none;">
				<div class="preloader"></div>
			</div>
			<p onclick="ajax_sourch_submit();" id="load_more"><span class="icon icon-down"></span> 点击加载更多...</p>
			
			
			
			<div class="activity_from_bg discuss_1 discuss_close" style="display: none;"></div>
			<div class="activity_from discuss_from discuss_1" style="display: none;">
				
				<!-- <form action="" method="post" id="discuss_form"> -->
					<div class="list-block">
					<span id="form_query" class="discuss_from_btn discuss_close">确定</span>
					<span class="discuss_from_btn discuss_from_btn2 discuss_close">取消</span>
						<div class="item-title text-center">我要讨论</div>
				    <ul>
				      <!-- Text inputs -->
				      <li>
				        <div class="item-content">
				          <div class="item-inner">
				            <div class="item-input">
				            	<textarea name="content" class="js_discuss_bottom_text" placeholder="讨论.."></textarea>
				            </div>
				          </div>
				        </div>
				      </li>
				    </ul>
				  </div>
				  <div class="content-block">
				    <div class="row">
				    </div>
				  </div>
			   <!-- </form> -->
			</div>
</div>

{include file="Public:footer" /}

<script>
//Zepto.toast('操作成功，正在跳转...', 2000, 'success top');
var activity_id = {$Think.get.activity_id};
var  page = 1;
 /*** ajax 提交表单 查询订单列表结果*/  
 function ajax_sourch_submit()
 {	 	 	 
	 	$(".infinite-scroll-preloader").show();
        page += 1;
		$.ajax({
			type : "GET",
			//url:"/index.php?m=Mobile&c=User&a=collect_list&is_ajax=1&p="+page,//+tab,			
			url:"/ActivityDetail/Discuss/activity_id/"+activity_id+"/is_ajax/1/p/"+page,// /activity_id/"+activity_id+"/is_ajax/1/p/"+page,//+tab,
//			data : $('#filter_form').serialize(),// 你的formid 搜索表单 序列化提交
			success: function(data)
			{
				$(".infinite-scroll-preloader").hide();
				if($.trim(data) == ''){
					$('#load_more').hide();
				}else{
				    $("#discuss_ul").append(data);
				}
			}
		}); 
 } 
</script>
<script>
var reply_user_id = '';
var reply_nickname = '';
function discuss_form(user_id, nickname){
	reply_user_id = user_id;
	reply_nickname = nickname;
	var text_placeholder = '';
	if(reply_nickname){
	    text_placeholder = '回复'+reply_nickname+'...';
	}else{
		text_placeholder = '讨论...'
	}
	$(".discuss_1").slideToggle();
	$("textarea[name='content']").attr('placeholder', text_placeholder);
}

$("#form_query").click(function(){
	var content = $("textarea[name='content']").val();
	if(content.length <= 0){
		Zepto.toast('请输入讨论内容', 2000, 'success top');
	}else if(content.length > 0 && content.length < 100){
		 $.ajax({
			type : "POST",
			//url:"/index.php?m=Mobile&c=User&a=collect_list&is_ajax=1&p="+page,//+tab,			
			url:"{:U('ActivityDetail/addDiscuss')}",//+tab,
			data : {'content':content, 'activity_id':activity_id,'reply_user_id':reply_user_id,'reply_nickname':reply_nickname},// 你的formid 搜索表单 序列化提交
			dataType : 'html',
			success: function(data){
				if(data != false){
					$("#discuss_ul").prepend(data);
					Zepto.toast('讨论成功', 2000, 'success top');
				}else{
					Zepto.toast('讨论失败!', 2000, 'success top');
				}
				$("textarea[name='content']").val('');
			}
		});  
	}
});
</script>